// pages/diancan/diancan.js
const app = getApp();
Page({

  /**
   * 页面的初始数据
   */

  data: {
    condition: Math.floor(Math.random() * 7 + 1),
    selindex: 0,
    toView: '',
    ischange: false,
    list:'' ,
  },
  dingwei: function (e) {
    wx.navigateTo({
      url: '../maptext/maptext'
    })
  },

  clickScroll: function (e) {
    var id = e.currentTarget.id
    console.log(id);
    this.setData({
      toView: id
    })
  },

  changeback: function (e) {
    var myischange = !this.data.ischange;
    this.setData({
      ischange: myischange
    })
    wx.navigateTo({
      url: '../maptext/maptext',
    })
  },

  sj: function (e) {
    this.setData({
      showModal: true
    })
    var that = this;
    this.interval = setInterval(function () {
      that.changeContent();
    }, 10)
  },

  changeContent: function () {
    var isShow = this.data.condition;
    this.setData({
      condition: Math.floor(Math.random() * 7 + 1)
    })
  },

  endMotto: function () {
    clearInterval(this.interval);
  },

  hidepopup: function () {
    this.setData({
      showModal: false
    });
  },

  btn: function (e) {
    app.globalData.productId = e.currentTarget.dataset.product_id;
    app.globalData.productName = e.currentTarget.dataset.product_name;
    app.globalData.productDesc = e.currentTarget.dataset.product_desc;
    app.globalData.productPrice = e.currentTarget.dataset.product_price;
    app.globalData.productIcno = e.currentTarget.dataset.product_icno;
    
    console.log(app.globalData.productId)
    console.log(app.globalData.productName)
    console.log(app.globalData.productDesc)
    console.log(app.globalData.productPrice)
    console.log(app.globalData.productIcno)

    wx.redirectTo({
      url: '/pages/gouwuche/gouwuche',
    })
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    wx.showLoading({
      title: '玩命加载中',
    })
    var that= this;
    wx.request({
      url: 'http://localhost:13000/milktea/CatagoryInfoController',
      method:'POST',
      header:'application/json',
      success:function(e){
        console.log(e.data);
        that.setData({list:e.data});
      },
      fail:function(e){
        console.log("加载数据失败")
      },
      complete:function(e){
        wx.showToast({
          title: '加载完成',
        }),
        wx.hideLoading()
      }
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})